package iterator;

import java.util.ArrayList;

/**
 * @author czt
 * @version 1.0
 * @since 2024/12/23
 */
@SuppressWarnings("all")
public class BookShelf implements Aggregate{

    private ArrayList<Book> books;

    public BookShelf(int maxsize) {
        this.books = new ArrayList<>(maxsize);
    }

    public Book getBookAt(int index) {
        return books.get(index);
    }

    public void appendBook(Book book) {
        books.add(book);
    }

    public int getLength() {
        return books.size();
    }

    @Override
    public Iterator iterator() {
        return new BookShelfIterator(this);
    }

}
